﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LogicUniversityBiz;

namespace LogicUniversity.clerks
{
    public partial class UpdateCatalogue : System.Web.UI.Page
    {
        protected void Page_PreInit(Object sender, EventArgs e)
        {
            //(Session["Role"]
            if (Session["Role"] as string != "Clerk")
            {
                Response.Redirect("~/Login.aspx");
            }

        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            { 
                 CatalogueMaintain cm = new CatalogueMaintain();
                    List<Catelogue> lc = new List<Catelogue>();
                    
                    DropDownList1.Items.Add("Pencil");
                    DropDownList1.Items.Add("Envelope");
                    DropDownList1.Items.Add("Clip");
                    DropDownList1.Items.Add("Eraser");
                    DropDownList1.Items.Add("Exercise");
                    DropDownList1.Items.Add("File");
                    DropDownList1.Items.Add("Pen");
                    DropDownList1.Items.Add("Puncher");
                    DropDownList1.Enabled = false;
                    DropDownList2.Items.Add("Packet");
                    DropDownList2.Items.Add("Dozen");
                    DropDownList2.Items.Add("Box");
                    DropDownList2.Items.Add("Each");
                    DropDownList2.Items.Add("Set");
                    txtItemcode.Enabled = false;
                    txtItemcode.Text = Session["Item_Code"].ToString();
                    txtReorderlevel.Text = Session["Reorder_Level"].ToString();
                    txtReorderqty.Text = Session["Reorder_Qty"].ToString();
                    txtDescrip.Text = Session["Item_Description"].ToString();
                    txtBin.Text = Session["Bin"].ToString();
                   // DropDownList1.Text = Session["Category"].ToString();
                  //  DropDownList2.Text = Session["Measurement"].ToString();
                    Session.Remove("Item_Code");
                    Session.Remove("Reorder_Level");
                    Session.Remove("Reorder_Qty");
                    Session.Remove("Item_Description");
                    Session.Remove("Bin");
                   // Session.Remove("Category");
                    //Session.Remove("Measurement");
                   
                }
            }

        protected void Button1_Click(object sender, EventArgs e)
        {
            CatalogueMaintain cm = new CatalogueMaintain();
            cm.updateCatalogue(txtItemcode.Text, DropDownList1.SelectedItem.Value, Convert.ToInt32(txtBin.Text),
                Convert.ToInt32(txtReorderlevel.Text), Convert.ToInt32(txtReorderqty.Text),
                DropDownList2.SelectedItem.Value, txtDescrip.Text);
            Response.Redirect("MaintainCatalogueInfo.aspx");
        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Response.Redirect("MaintainCatalogueInfo.aspx");
        }

        }
  }
